import numpy as np
import HS
import matplotlib.pyplot as plt
if __name__ == "__main__":

    vardim = 30
    a = []
    b = []
    for i in range(10):
        bound = np.tile([[-100.0], [100.0]], vardim)
        hs1 = HS.HarmonySearch(100, vardim, bound, 5000, [0.9950, 0.4,0.0008])
        hs1.solve()
        a.append(hs1.trace[:, 0])
        bound = np.tile([[-100.0], [100.0]], vardim)
        hs2 = HS.HarmonySearch(10, vardim, bound, 5000, [0.9950, 0.4,0.0008])
        hs2.solve()
        b.append(hs2.trace[:, 0])
    # x = np.arange(0, 10000)
    print(f"hs-100 MEAN:{np.mean(a)}, STD:{np.std(a)}")
    print(f"hs-10 MEAN:{np.mean(b)}, STD:{np.std(b)}")
    y1 = hs1.trace[:, 0]
    y2 = hs2.trace[:, 0]
    plt.plot(y1,label= 'HS-100 best value')
    plt.plot(y2, label='HS-10 best value')
    plt.legend()
    plt.show()

